package com.fjec.market.controller;

import com.fjec.common.protocol.JsonResult;
import com.fjec.common.util.SpecialMapUtil;
import com.fjec.market.entity.InfoBusiness;
import com.fjec.market.service.IInfoBusinessService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 005.商户表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2020-09-07
 */
@RestController
@RequestMapping("/")
public class InfoBusinessController {

    @Autowired
    private IInfoBusinessService infoBusinessService;

    @GetMapping("/y/business/getByUserId")
    public JsonResult getBusinessByUserId(Long userId) {
        Map<String, Object> result = infoBusinessService.getBusinessByUserId(userId);
        return JsonResult.success().data(result).build();
    }

    @PostMapping("/y/business/save")
    public JsonResult saveBusiness(InfoBusiness business, String markCodes, Long headPicId, String verifyCode) {
        return infoBusinessService.saveBusiness(business, markCodes, headPicId, verifyCode);
    }

//    @GetMapping("/y/business/getDepoStatus")
//    public JsonResult getDepoStatus(@RequestParam(required = false) Long userId) {
//        return infoBusinessService.getDepoStatus(userId);
//    }

    @GetMapping("/business/getBusiIdByBusiName")
    public List<Long> getUserIdByBusiNameES(@RequestParam("title") String title) {
        List<Long> result = infoBusinessService.getUserIdByBusiNameES(title);
        return result;
    }

    @PostMapping("/business/getBusiNamesByBusiIdOrUserIds")
    public List<Map<String, Object>> getBusiNamesByBusiIdOrUserIds(@RequestBody List<Long> busiIdOrUserIds) {
        List<Map<String, Object>> result = infoBusinessService.getBusiNamesByBusiIdOrUserIds(busiIdOrUserIds);
        return result;
    }
}